import request from '@/utils/request';
import {object2Url} from "@/utils/trans";

/* seo文案 */

// 省市区展示，区域管理，直接搜之前的接口

// 添加SEO文案
export async function addSeo (data) {
  const res = await request.post('/business/matrix/seo/add', data)
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 修改SEO文案
export async function updateSeo (data) {
  const res = await request.post('/business/matrix/seo/update', data)
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 删除SEO文案【真实删除】
export async function delSeo (data) {
  const res = await request.post('/business/matrix/seo/delete', data)
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询SEO文案【分页查询】
export async function querySeo (data) {
  const res = await request.post('/business/matrix/seo/page', data)
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询代理区域
export async function areaAll (data) {
  const res = await request.post('/auth/proxyarea/all', data)
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 默认SEO词库查询
export async function seodefaultList(type) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    ts,
    ua,
    type: type
  };
  // ${object2Url(us)} get 链接传值
  let url = `/business/matrix/seodefault/list${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}




